hysop.backend.host.python.operator.directional.stretching_dir module¶
- class hysop.backend.host.python.operator.directional.stretching_dir.PythonDirectionalStretching(formulation, **kwds)[source]¶
Bases:
DirectionalStretchingBase
,HostDirectionalOperator
Initialize directional stretching operator python backend.
Solves dW/dt = C * f(U,W) where U is the velocity, W the vorticity and f is one of the following formulation:
CONSERVATIVE FORMULATION: f(U,W) = div( U : W ) MIXED GRADIENT FORMULATION: f(U,W) = (A*grad(U) + (1-A)*grad(U)^T) . W
- whererepresents the outer product U:W = (Ui*Wj)ij.
. represents the matrix-vector product.
^T is the transposition operator
U and W are always three dimensional fields. C is scalar or 3d vector-like of symbolic coefficients. A is a scalar symbolic coefficient. f(U,W) is always directionally splittable.
- Parameters:
formulation (hysop.constants.StretchingFormulation) –
The formulation of this stretching operator: CONSERVATIVE: f(U,W) = div( U : W ) GRAD_UW: f(U,W) = grad(U) . W GRAD_UW_T: f(U,W) = grad(U)^T . W MIXED_GRAD_UW: f(U,W) = (A*grad(U) + (1-A)*grad(U)^T) . W
where A is a user given scalar or 3d vector like that contains scalar (floating point) coefficient(s) or parameter(s). The most common mixed gradient formulation is A=0.5.
Only CONSERVATIVE formulation is implemented yet in python.
velocity (Field) – Velocity U as read-only input three-dimensional continuous field.
vorticity (Field) – Vorticity W as read-write three-dimensional continuous field.
variables (dict) – Dictionary of fields as keys and topology descriptors as values.
dt (ScalarParameter) – Timestep parameter that will be used for time integration.
C (scalar or vector like of 3 symbolic coefficients, optional) – The stretching leading coefficient C can be scalar or vector like. Contained values should be numerical coefficients, parameters or generic symbolic expressions such that C*f(U,W) is directionally splittable. Here * is the classical elementwise multiplication. Default value is 1.
A (scalar symbolic coefficient, optional) – Should only be given for MIXED_GRAD_UW formulations. ValueError will be raised on other formulations. The linear combination coefficients A is a scalar. Contained value should be a numerical coefficient, a parameter (or a generic symbolic expression) such that C*(A*grad(U).W + (1-A)*grad^T(U).W) is directionally splittable. Here * is the classical elementwise multiplication. Default value is 0.5.
name (str, optional, defaults to 'stretching'.) – Name of this stretching operator.
implementation (Implementation, optional, defaults to None) – Target implementation, should be contained in available_implementations(). If None, implementation will be set to default_implementation().
base_kwds (dict, optional, defaults to None) – Base class keywords arguments. If None, an empty dict will be passed.
kwds – Keywords arguments that will be passed towards implementation operator __init__.
- apply(**kwds)¶
Abstract method that should be implemented. Applies this node (operator, computational graph operator…).
- discretize(**kwds)[source]¶
By default, an operator discretize all its variables. For each input continuous field that is also an output field, input topology may be different from the output topology.
After this call, one can access self.input_discrete_fields and self.output_discrete_fields, which contains input and output dicretised fields mapped by continuous fields.
self.discrete_fields will be a tuple containing all input and output discrete fields.
Discrete tensor fields are built back from discretized scalar fields and are accessible from self.input_tensor_fields, self.output_tensor_fields and self.discrete_tensor_fields like their scalar counterpart.
- get_work_properties()[source]¶
Returns extra memory requirements of this operator. This allows operators to request for temporary buffers that will be shared between operators in a graph to reduce the memory footprint and the number of allocations.
Returned memory is only usable during operator call (ie. in self.apply). Temporary buffers may be shared between different operators as determined by the graph builder.
By default if there is no input nor output temprary fields, this returns no requests, meanning that this node requires no extra buffers.
If temporary fields are present, their memory request are automatically computed and returned.
- setup(work)[source]¶
Setup temporary buffer that have been requested in get_work_properties(). This function may be used to execute post allocation routines. This sets self.ready flag to True. Once this flag is set one may call ComputationalGraphNode.apply() and ComputationalGraphNode.finalize().
Automatically honour temporary field memory requests.